var a = getApp();

Page({
    data: {
        active: "capital_pool_records",
        performance_total: "",
        finished_quota: "",
        waiting_quota: "",
        capital_pool: "",
        capital_pool_records: {},
        love_speed_pool: {},
        diy_names: {},
        amount_total: ""
    },
    onChange: function(a) {
        this.setData({
            active: a.detail.name
        });
    },
    getAccountBalance: function() {
        var t = this;
        a._getNetWork({
            url: a.getNetAddresss("plugin.love-speed-pool.frontend.plus.index"),
            success: function(e) {
                1 == e.data.result ? t.setData({
                    amount_total: e.data.data.amount_total,
                    love_speed_pool: e.data.data.list
                }) : a.tips(e.data.msg);
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    RedPacket: function() {
        wx.navigateTo({
            url: "/packageA/member/redPacket/redPacket"
        });
    },
    onLoad: function() {
        this.getData(), this.getAccountBalance();
    },
    getData: function() {
        var t = this;
        a._getNetWork({
            url: a.getNetAddresss("plugin.love-speed-pool.frontend.newHome.index"),
            success: function(e) {
                if (1 == e.data.result) {
                    var o = e.data.data, n = o.performance_total, i = o.finished_quota, l = o.waiting_quota, s = o.capital_pool, d = o.capital_pool_records, c = o.diy_name, p = o.diy_names;
                    t.setData({
                        diy_names: p,
                        diy_name: c,
                        performance_total: n,
                        finished_quota: i,
                        waiting_quota: l,
                        capital_pool: s,
                        capital_pool_records: d
                    }), wx.setNavigationBarTitle({
                        title: c || "资金池"
                    });
                } else a.tips(e.data.msg);
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        var t = this;
        if ("capital_pool_records" == this.data.active) {
            if (this.data.capital_pool_records.current_page >= this.data.capital_pool_records.last_page) return !1;
            var e = this.data.capital_pool_records.current_page + 1;
            a._getNetWork({
                url: a.getNetAddresss("plugin.love-speed-pool.frontend.newHome.index"),
                data: {
                    page: e
                },
                success: function(e) {
                    if (1 == e.data.result) {
                        var o = e.data.data, n = o.performance_total, i = o.finished_quota, l = o.waiting_quota, s = o.capital_pool, d = o.capital_pool_records, c = t.data.capital_pool_records.data.concat(d.data);
                        t.setData({
                            performance_total: n,
                            finished_quota: i,
                            waiting_quota: l,
                            capital_pool: s,
                            "capital_pool_records.data": c,
                            "capital_pool_records.current_page": d.last_page
                        });
                    } else a.tips(e.data.msg);
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        } else {
            if (this.data.love_speed_pool.current_page >= this.data.love_speed_pool.last_page) return !1;
            var o = this.data.love_speed_pool.current_page + 1;
            a._getNetWork({
                url: a.getNetAddresss("plugin.love-speed-pool.frontend.plus.index"),
                data: {
                    page: o
                },
                success: function(e) {
                    if (1 == e.data.result) {
                        var o = t.data.love_speed_pool.data.concat(e.data.data.list.data);
                        t.setData({
                            "love_speed_pool.data": o,
                            "love_speed_pool.current_page": e.data.data.list.current_page
                        });
                    } else a.tips(e.data.msg);
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    },
    onShareAppMessage: function() {}
});